/*
 * @Author: Setsuna
 * @Email: 601890383@qq.com
 * @FilePath: \src\components\SetApproveModal\index.tsx
 * @Date: 2021-09-23 20:37:47
 * @LastEditTime: 2021-10-13 11:21:30
 */
import React, { useState } from 'react'
import { UdModalForm, validators } from '@/lib'
import { Radio, Input } from 'antd'
import UdUploader from '../UdUploader/Uploader'
const TextArea = Input.TextArea
export default function (props) {
  const {
    params: { modalItems = [] },
    updateFiles,
    ...reset
  } = props
  const [isValid, setIsValid] = useState(null)
  let formItems = isValid === 0 ? modalItems : []
  return (
    <UdModalForm
      {...reset}
      items={[
        {
          id: 'isValid',
          label: '审批状态',
          rules: [validators.required],
          render: (
            <Radio.Group onChange={e => setIsValid(e.target.value)}>
              <Radio value={0}>审批通过</Radio>
              <Radio value={1}>不通过</Radio>
            </Radio.Group>
          ),
        },
        {
          id: 'comment',
          label: '审批意见',
          rules: [validators.max(100), validators.noSpecialSymbol],
          render: <TextArea placeholder="请填写审批意见（限100字）" />,
        },
        {
          id: 'files',
          label: '凭证附件',
          render: <UdUploader updateFiles={updateFiles} extra="支持扩展名：.jpg .png .xls .doc" />,
        },
        ...formItems,
      ]}
    />
  )
}
